﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace NimLearning
{
	public class NimBoard
	{
		bool[][] board;
		Random rambo = new Random();
		public NimBoard()
		{
			board = new bool[3][];
			Initialize();
			
		}
		public void Remove(int heap, int count)
		{
			for (int i = 0; i < count; i++)
			{
				board[heap - 1][board.Length - i] = false;
			}
		}
		private void Initialize()
        {
			for (int x = 0; x < board.Length;x++ )
			{
				int length = rambo.Next(3, 11);
				board[x] = new bool[length];
				for (int i = 0; i < board[x].Length ; i++)
				{
					board[x][i] = true;
				}
			}

        }
		public int LengthOfRow(int row)
		{
			int length = 0;
			for (int i = 0; i < board[row-1].Length; i++)
			{
				if (board[row-1][i])
					length++;
			}
			return length;
		}
		public bool ValidRow(int row)
		{
			bool result = true;
			int Row = row - 1;
			for (int i = 0; i < this.board[Row].Length; i++)
			{
				if (!board[Row][i])
					result = false;

			}
			return result;
		}

		public void PrintBoard()
		{
			for (int i = 0; i < board.Length; i++)
			{
				for (int x = 0; x < board[i].Length; x++)
				{
					if(board[i][x] == true)
						Console.Write("X");
				}
				Console.WriteLine();
			}
		}
	}
}